﻿<UserControl 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             
             xmlns:vm="clr-namespace:CaliburnWpf.ViewModels;assembly=CaliburnWpf.ViewModels"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
             x:Class="CaliburnWpf.Views.HomeView" 
             mc:Ignorable="d" 
             
             d:DesignHeight="300" d:DesignWidth="300" 
             d:DataContext="{x:Static vm:DesignTimeViewModelSupplier.Home}" >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="summary:  "/>
            <TextBlock Text="{Binding Date}"/>
        </StackPanel>
        <WrapPanel Grid.Row="1">
        	<i:Interaction.Behaviors>
        		<ei:FluidMoveBehavior AppliesTo="Children">
        			<ei:FluidMoveBehavior.EaseY>
        				<BackEase EasingMode="EaseOut"/>
        			</ei:FluidMoveBehavior.EaseY>
        			<ei:FluidMoveBehavior.EaseX>
        				<BackEase EasingMode="EaseOut"/>
        			</ei:FluidMoveBehavior.EaseX>
        		</ei:FluidMoveBehavior>
        	</i:Interaction.Behaviors>
            <GroupBox  >
                <GroupBox.Header>
                    
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
                        <TextBlock Text=" BankAccounts[ "/>
                        <TextBlock Text="{Binding CurrentMonthIncome}" Foreground="Blue"/>
                        <TextBlock Text="  &lt;==&gt;  "/>
                        <TextBlock Text="{Binding CurrentMonthExpense}" Foreground="Red"/>
                        <TextBlock Text=" ]"/>
                    </StackPanel>
                </GroupBox.Header>
                <ListBox ItemsSource="{Binding BankAccounts}" BorderThickness="0" >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Name}"/>
                            <TextBlock Text=" : "/>
                            <TextBlock Text="{Binding Summary}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            </GroupBox>
           
            
            

            <GroupBox >
                <GroupBox.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Top "/>
                        <TextBlock Text="{Binding TopNumber}"/>
                        <TextBlock Text=" transactions for last 30 days"/>
                        
                    </StackPanel>
                </GroupBox.Header>
                    
                
                
            

            <DataGrid  Background="White"
                       AutoGenerateColumns="False" 
                       EnableRowVirtualization="True" 
                       AlternatingRowBackground="AliceBlue" 
                       x:Name="transactionSetDataGrid" Grid.Row="1" CanUserAddRows="False" IsReadOnly="True" ItemsSource="{Binding TopTransactions}">
                <DataGrid.Columns>

                    <DataGridTemplateColumn x:Name="categoryColumn" Header="Category" Width="Auto">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Text="{Binding Category.Name}" />
                                    <TextBlock Text=" : "/>
                                    <TextBlock Text="{Binding SubCategory.Name}" />
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>

                    <DataGridTextColumn x:Name="amountColumn" Binding="{Binding Amount}" Header="Amount" Width="SizeToHeader" />
                    
                    <DataGridTextColumn x:Name="contragentColumn" Binding="{Binding Contragent.Name}" Header="Contragent" Width="SizeToHeader" />
                    <DataGridTemplateColumn x:Name="accountColumn" Header="Account" Width="Auto">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding FromAccount.Name}" Foreground="Red"/>
                                    <TextBlock Text="-&gt;"/>
                                    <TextBlock Text="{Binding ToAccount.Name}" Foreground="Green"/>
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>


            </GroupBox>
            
            
            <GroupBox Header="Stock accounts">
                <ListBox ItemsSource="{Binding StockAccounts}" BorderThickness="0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}"/>
                                <TextBlock Text=" : "/>
                                <TextBlock Text="{Binding Summary}" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </GroupBox>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom"/>

        </WrapPanel>

    </Grid>
</UserControl>
